package com.jic.market.common.enums;

import java.util.EnumSet;

/**
 * @author : xuyongliang
 * @date : 2020/2/29 5:59 PM
 * @description: ${description}
 * @modified By:
 * @version: V1.0
 */
public enum MutexFlagEnum {

    // 是否与其他活动互斥 0 否(默认值)   1 是
    // 注意这个不同于  PromotionMutexConstants
    UN_MUTEX(0, "不互斥"),
    MUTEX(1, "互斥");

    private Integer code;

    private String value;

    MutexFlagEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static MutexFlagEnum getEnumByCode(Integer code){
        EnumSet<MutexFlagEnum> elements = EnumSet.allOf(MutexFlagEnum.class);
        for(MutexFlagEnum enumType : elements){
            if(enumType.getCode().equals(code)){
                return enumType;
            }
        }
        return null;
    }

    public static String getValue(Integer code) {
        return getEnumByCode(code).getValue();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
